# -*- coding: utf-8 -*-
from cmsdj.categories.models import Category
from cmsdj.content.models import Content
from django.shortcuts import render_to_response, get_object_or_404
from django.template.context import RequestContext
from cmsdj.cfg.models import SiteCfg

def list (request):
    return render_to_response (SiteCfg.current_cfg().template + '/categories/index.html', context_instance=RequestContext(request))

def details (request, slug):    
    category = get_object_or_404(Category, slug = slug)
    contents = Content.get_by_category(category)
    return render_to_response (SiteCfg.current_cfg().template + '/categories/details.html', {'category': category, 'contents': contents}, context_instance=RequestContext(request))

def nav (request):
    return render_to_response (SiteCfg.current_cfg().template + '/categories/nav_bar.html', context_instance=RequestContext(request))
